﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Default.Master" AutoEventWireup="true"
  CodeBehind="NewsLetterPage.aspx.cs" Inherits="ITViet.Web.Pages.NewsLetterPage" %>

<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Src="~/Controls/AlertMessage.ascx" TagName="AlertMessage" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphContentMain" runat="server">
  <div style="width:100%;">
    <table style="margin:0 auto;">
      <tr>
        <td colspan="2">
          <asp:Literal ID="Literal3" runat="server" Text="<%$Resources:Strings, NewsLetterIntroduction %>"></asp:Literal>
        </td>
      </tr>
      <tr>
        <td>
          <asp:Literal runat="server" Text="<%$Resources:Strings, Email %>"></asp:Literal>
        </td>
        <td>
          <dxe:ASPxTextBox ID="txtEmail" ClientInstanceName="txtEmail" runat="server" Width="300px">
          </dxe:ASPxTextBox>
        </td>
      </tr>
      <tr>
        <td>
          <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:Strings, CustomerName %>"></asp:Literal>
        </td>
        <td>
          <dxe:ASPxTextBox ID="txtName" ClientInstanceName="txtName" runat="server" Width="300px">
          </dxe:ASPxTextBox>
        </td>
      </tr>
      <tr>
        <td>
          <asp:Literal ID="Literal2" runat="server" Text="<%$Resources:Strings, Note %>"></asp:Literal>
        </td>
        <td>
          <dxe:ASPxMemo ID="mmNote" ClientInstanceName="mmNote" runat="server" Height="71px"
            Width="300px">
          </dxe:ASPxMemo>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td>
          <div style="float: left">
            <a class="btn" href="javascript:onSend();"><span><strong>
              <%=GetGlobalResourceObject("Strings", "Send") %></span></strong></a>
          </div>
          <div style="float: left">
            <a class="btn btn_next" href="javascript:onCancel();"><span><strong>
              <%=GetGlobalResourceObject("Strings", "Cancel") %></span></strong></a>
          </div>
        </td>
      </tr>
    </table>
  </div>
  <div>
    <dxcb:ASPxCallback ID="ctrlCallback" ClientInstanceName="ctrlCallback" 
      runat="server" oncallback="ctrlCallback_Callback">
      <ClientSideEvents CallbackComplete="function (s,e){ctrlCallback_CallbackComplete(s,e);}" />
    </dxcb:ASPxCallback>
    <uc1:AlertMessage ID="AlertMessage1" runat="server" />
    <script type="text/ecmascript" language="javascript">
      function onSend() {
        if (Validate()) {
          ctrlCallback.SendCallback("save");
        }
      }

      function onCancel() {
        //document.forms[0].reset();
        txtEmail.SetText("");
        txtName.SetText("");
        mmNote.SetText("");
      }

      function Validate() {
        if (!ValidateEmail(txtEmail.GetText())) {
          alertMessage('<%=(string)GetGlobalResourceObject("Messages", "ERR0059") %>');
          return false;
        }
        return true;
      }

      function ctrlCallback_CallbackComplete(s, e) {
        if (e.result != "")
          alertMessage(e.result);
        else {
          alertMessage('<%=(string)GetGlobalResourceObject("Messages", "ERR0005") %>');
          onCancel();
        }
      }
      
    </script>

  </div>
</asp:Content>
